function Enemy(_level,direc) {
    this.enemy;
    this.enemyX;
    this.enemyY;
    this.enemyIndex;
    this.level = _level;
    this.hitCounts = 0;
    this.direc = direc||'right';
    this.isGo = true;
    this.load();
}
Enemy.prototype.load = function () {
    
    this.enemy = $('<div class="enemy">');
    Game.container.append(this.enemy);
    Game.enemyArr.push(this);
    this.enemyIndex = Game.enemyArr.indexOf(this);
    this.hitCounts = 0;
    this.fly();
}
Enemy.prototype.fly = function () {
    
    this.enemyY = '-25';
    var self = this;
    if(this.direc == 'left'){
        this.enemyX = '25%';
        this.enemy.css({
            'top': this.enemyY + 'px',
            'left': this.enemyX
        });
    }else{
        this.enemyX = '75%';
        this.enemy.css({
            'top': this.enemyY + 'px',
            'left': Game.container.width() * 75 / 100 - 50 + 'px'
        });
    }
    
    var _top = 0;
    function flyself() {
        setTimeout(function () {
            _top++;
            self.enemyIndex = Game.enemyArr.indexOf(self);
            if(_top >= Game.container.height() + self.enemy.height()){
                self.destroyed();
                return;
            }
            self.enemy.css({
                'top': self.enemyY * 1 + _top + 'px'
            });
            if(self.isGo){
                flyself();
            }
        },16.7)
    }
    flyself();
}
Enemy.prototype.destroyed = function(){
    this.enemy.css('background-color','blue');
    this.isGo = false;
    var self = this;
    setTimeout(function(){
        self.enemy.remove();
        var index = Game.enemyArr.indexOf(self)
        delete Game.enemyArr[index];
    },300);
}